<template>
  <ContentWrap
    class="mb-0!"
    :class="[
      footer
        ? '!h-[calc(80vh-var(--top-tool-height)-var(--tags-view-height)-var(--app-footer-height)-10px)]'
        : '!h-[calc(80vh-var(--top-tool-height)-var(--tags-view-height)-var(--app-footer-height)-10px)]'
    ]"
    :bodyStyle="{ height: '100%', padding: '10px' }"
  >
    <div class="flex flex-col !h-full justify-between">
      <div class="flex">
        <slot name="tool"></slot>
      </div>
      <el-scrollbar>
        <el-row v-infinite-scroll="load" :infinite-scroll-immediate="false" v-if="list.length > 0"
          ><el-col
            :xs="6"
            :sm="6"
            :md="6"
            :lg="6"
            :xl="4"
            v-for="(item, index) in list"
            :key="index"
          >
            <ReplaceItem :spuItem="item">
              <template #itemButton>
                <el-button class="mt-10px w-100%" type="primary" @click="handleBuy(item)">
                  换卡
                </el-button>
              </template>
            </ReplaceItem>
          </el-col>
        </el-row>
      </el-scrollbar>
      <div class="h-full flex flex-col justify-center" v-if="list.length == 0">
        <Empty />
      </div>
    </div>
  </ContentWrap>
</template>
<script lang="ts" setup>
import { propTypes } from '@/utils/propTypes'
import { useAppStore } from '@/store/modules/app'
const appStore = useAppStore()
const footer = computed(() => appStore.getFooter)
const emit = defineEmits(['handleBuy', 'load'])
const load = () => {
  emit('load')
}
defineOptions({ name: 'ReplaceList' })
defineProps({
  // 选中的门店列表
  list: propTypes.arrayOf(propTypes.object).def([])
})
import ReplaceItem from './ReplaceItem.vue'
const handleBuy = (item: any) => {
  emit('handleBuy', item)
}
</script>
<style lang="scss"></style>
